<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 *    Document   : message_helper
 *   Created on : May 19, 2011, 3:00:44 AM
 *    Author     : ClarkT AKA FalleN
 *    Company    : Amodity
 *    Web        : http://www.amodity.com
 *    Copyright  : 2011
 */

/**
 * Display Helper
 *
 * Provide helper functions for common display operations.
 *
 */

/**
 * Display formatted error message.
 * 
 * @access public 
 * @param string
 * @param string
 * @return string
 */
function display_alert($alert, $type = null) {
    // Make sure an error message is provided.
    if ($alert) {
        // Determine what type of error to return.
        switch ($type) {
            case 'success':
                return '<p class="notification success">' . $alert . '</p>';
                break;

            case 'warning':
                return '<p class="notification warning">' . $alert . '</p>';
                break;
            
            case 'info':
                return '<p class="notification info">' . $alert . '</p>';
                break;
            
            case 'tip':
                return '<p class="notification tip">' . $alert . '</p>';
                break;
            
            default:
                return '<p class="notification error">' . $alert . '</p>';
                break;
        }
    }
}

/**
 * Display formatted system message.
 * 
 * @access public 
 * @param string
 * @return string
 */
function display_msg($msg) {
    if ($msg) {
        return '<p id="alert-yellow">' . $msg . '</p>';
    }
}

/**
 * Display required field flag.
 * 
 * @access public 
 * @return string
 */
function req_field() {
    return '<em>*</em>';
}

/**
 * Generate HTML code for JS confirmation boxes displaying a provided message.
 * 
 * @access public 
 * @param string
 * @return string
 */
function js_confirm($msg = NULL) {
    if ($msg == NULL) {
        $message = 'Are you sure?';
    } else {
        $message = $msg;
    }

    return 'onclick="return confirm(\'' . $message . '\');"';
}

/* End of file display_helper.php */
/* Location: ./application/helpers/display_helper.php */
?>
